<template>
    <div>
        <el-table :data="tableData" border style="width: 100% ; line-height: 30px;" v-loading="loading"
            element-loading-text="拼命加载中" element-loading-spinner="el-icon-loading">
            <el-table-column prop="orderTime" label="下单时间" width="150">
            </el-table-column>
            <el-table-column fixed prop="id" label="订单号" width="150">
            </el-table-column>
            <el-table-column prop="consignee" label="收件人" width="150">
            </el-table-column>
            <el-table-column prop="consigneeAddress" label="收件地址" width="150">
            </el-table-column>
            <el-table-column prop="consigneePhone" label="收件人预留电话" width="200">
            </el-table-column>
            <el-table-column prop="marketerName" label="商家名称" width="150">
            </el-table-column>
            <el-table-column prop="marketerAddress" label="商家地址" width="150">
            </el-table-column>
            <el-table-column prop="marketerPhone" label="商家预留电话" width="150">
            </el-table-column>
            <el-table-column label="状态" width="150">
                <template slot-scope="scope">
                    <el-tag type="success">派送中</el-tag>
                </template>
            </el-table-column>
        </el-table>
    </div>
</template>
<script>
import {getShippedOrderData} from '@/utils/modules/employee.js'
export default {
    mounted() {
        this.getShippedOrderData()
    },
    data() {
        return {
            tableData:[],
            loading:true
        }
    },
    methods: {
        getShippedOrderData() {
            getShippedOrderData().then(res => {
                console.log(res.data)
                let data = JSON.parse(JSON.stringify(res.data.itemList))
                this.tableData = []
                for (let i = 0; i < data.length; i++) {
                    let consigneeAddress = data[i].consigneeProvince + data[i].consigneeCity + data[i].consigneeDistrict + data[i].consigneeDetail
                    let marketerAddress = data[i].marketerProvince + data[i].marketerCity + data[i].marketerDistrict + data[i].marketerDetail
                    if(data[i].marketerLabel != null){
                        marketerAddress += data[i].marketerLabel
                    }
                    if(data[i].consigneeLabel != null){
                        consigneeAddress += data[i].consigneeLabel
                    }
                    this.tableData.push({
                        'orderTime':data[i].orderTime,
                        'consigneeAddress': consigneeAddress,
                        'marketerAddress': marketerAddress,
                        'consigneePhone': data[i].consigneePhone,
                        'marketerPhone': data[i].marketerPhone,
                        'id': data[i].orderId,
                        'consignee': data[i].consignee,
                        'marketerName': data[i].marketerName
                    })
                }
            }).catch(err => {
                this.$message({
                    type: 'error',
                    message: err.message,
                    showClose: true
                })
            })
            this.loading = false
        }
    }
}
</script>